//
//  LBNormalBlendTextureFilter.mm
//  OpenGLGame
//
//  Created by Nguyen Cong Huy on 3/29/13.
//  Copyright (c) 2013 UIT. All rights reserved.
//

#include "LBNormalBlendTextureFilter.h"
#include "LBGraphics.h"

char fShaderStrNormalBlendTexture[] = ""
"precision mediump float;"

"varying vec2 vtexCoor;"
"varying vec4 vposition;"
"uniform sampler2D texture;"
"uniform sampler2D texture2;"
"uniform float opacity;"

"void main()"
"{"
"    lowp vec4 textureColor = texture2D(texture, vtexCoor);"
"    lowp vec4 blendColor = texture2D(texture2, vtexCoor);"
"    textureColor = mix(textureColor, blendColor, opacity*blendColor.a);"
"    gl_FragColor = textureColor;"
"}";

LBNormalBlendTextureFilter::LBNormalBlendTextureFilter(){
    init(0, fShaderStrNormalBlendTexture);
    LBGraphics::getInstance()->useProgram(program);
    opacityUniform = program->uniformIndex("opacity");
    setOpactiy(1.0f);
}